package com.nuanshui.heatedloan.baseservice.model;

import com.nuanshui.framework.lang.DateUtil;
import com.nuanshui.framework.res.ResourceFacade;
import com.nuanshui.framework.springContext.SpringContextUtil;
import com.nuanshui.heatedloan.dal.BaseEntityImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

public class SystemPicture  extends BaseEntityImpl{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String name;
	private String avatar;
	private String accessUrl;
	private Integer type;
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date showAt; //显示时间
	private String launchImageUrl;
	private String showAtStr;
	private Integer archive;//是否有效
	
	
	
	public Integer getArchive() {
		return archive;
	}
	public void setArchive(Integer archive) {
		this.archive = archive;
	}
	public String getShowAtStr(){
		return DateUtil.format(this.showAt, "yyyy-MM-dd HH:mm:ss");
	}
	public void setShowAtStr(String showAtStr) {
		this.showAtStr = showAtStr;
	}
	
	public String getImgUrl(){
		ResourceFacade resourceFacade = SpringContextUtil.getBean(ResourceFacade.class);
		if(resourceFacade != null && StringUtils.isNotEmpty(avatar)){
			return resourceFacade.resolveUrl(avatar);
		}
		return null;
	}
	
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getAvatar() {
		return avatar;
	}
	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}
	public String getAccessUrl() {
		return accessUrl;
	}
	public void setAccessUrl(String accessUrl) {
		this.accessUrl = accessUrl;
	}
	public Date getShowAt() {
		if(showAt == null && StringUtils.isNotEmpty(this.showAtStr)){
			this.showAt = DateUtil.stringToDate(this.showAtStr, "yyyy-MM-dd HH:mm:ss");
		}
		return showAt;
	}
	public void setShowAt(Date showAt) {
		this.showAt = showAt;
	}

	public String getLaunchImageUrl() {
		return launchImageUrl;
	}

	public void setLaunchImageUrl(String launchImageUrl) {
		this.launchImageUrl = launchImageUrl;
	}

}
